<template>
  <el-dialog :title="dialogProps.title" :visible.sync="dialogProps.visible" width="80%"
             @open="handleDialogOpen()" v-loading="loading">
<!--    {{bodyModel}}-->
    <div slot="title" class="dialog-header">{{ dialogProps.title }}</div>
    <el-form :model="bodyModel" :rules="formRules"
             ref="bodyTypeForm" label-width="80px" label-position="right" size="small">
      <!--<el-form-item v-show="dialogProps.isAdd" label="ID" prop="id">
        <el-col :span="16"><el-input ref="code" :maxlength="32" v-model="bodyModel.id" disabled ></el-input></el-col>
      </el-form-item>-->
      <el-form-item label="姓名" prop="name"  v-show="dialogProps.isAdd">
        <el-col :span="5"><el-input @keyup.native="queryIdCard()" :maxlength="32" v-model="bodyModel.name"></el-input></el-col>
      </el-form-item>
      <el-form-item label="姓名:" prop="name" v-show="!dialogProps.isAdd">
        <el-col :span="16">{{bodyModel.name}}</el-col>
      </el-form-item>
      <!--{{memberList}}-->
      <el-form-item  label="身份证号:" prop="idCard" >
        <el-col :span="5">
          <!--<el-input  v-model="bodyModel.idCard"></el-input>-->
          <el-select  v-model="bodyModel.idCard"  @change="selectIdCard()">
              <el-option
              v-for="item in memberList"
              :key="item.id"
              :label="item.idcard"
              :value="item.idcard">
            </el-option>
          </el-select>
            <!--@select="handleSelect"-->
          </el-col>
      </el-form-item>
      <el-tabs type="border-card" v-show="this.questions1 !='' ">
        <el-tab-pane>
          <span slot="label"><i class="el-icon-edit"></i> 阳虚质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions1" :key="item.id">
              <!--<p>{{item.question}}</p>-->
              <!--<el-radio-group v-model="isStart" v-show="item.isRadio==0" prop="question">
                <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.options" :key="value.id"></el-radio>
              </el-radio-group>-->
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div><!--{{questions}}-->

          </el-form>
        </el-tab-pane>
        <el-tab-pane>
          <span slot="label"><i class="el-icon-edit"></i> 阴虚质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions2" :key="item.id">
              <!--<p>{{item.question}}</p>-->
              <!--<el-radio-group v-model="isStart" v-show="item.isRadio==0" prop="question">
                <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.options" :key="value.id"></el-radio>
              </el-radio-group>-->
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div><!--{{questions}}-->

          </el-form>
        </el-tab-pane>
        <el-tab-pane>
          <span slot="label"><i class="el-icon-edit"></i> 气虚质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions3" :key="item.id">
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div><!--{{questions}}-->

          </el-form>
        </el-tab-pane>
        <el-tab-pane>
          <span slot="label"><i class="el-icon-edit"></i> 平和质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions4" :key="item.id">
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id"  :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div><!--{{questions}}-->

          </el-form>
        </el-tab-pane>
        <el-tab-pane>
          <span slot="label"><i class="el-icon-edit"></i> 痰湿质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions5" :key="item.id">
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div><!--{{questions}}-->

          </el-form>
        </el-tab-pane>
        <el-tab-pane>
          <span slot="label"><i class="el-icon-edit"></i> 湿热质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions6" :key="item.id">
              <!--<p>{{item.question}}</p>-->
              <!--<el-radio-group v-model="isStart" v-show="item.isRadio==0" prop="question">
                <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.options" :key="value.id"></el-radio>
              </el-radio-group>-->
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div><!--{{questions}}-->

          </el-form>
        </el-tab-pane>
        <el-tab-pane>
          <span slot="label"><i class="el-icon-edit"></i> 血瘀质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions7" :key="item.id">
              <!--<p>{{item.question}}</p>-->
              <!--<el-radio-group v-model="isStart" v-show="item.isRadio==0" prop="question">
                <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.options" :key="value.id"></el-radio>
              </el-radio-group>-->
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div><!--{{questions}}-->

          </el-form>
        </el-tab-pane>
        <el-tab-pane >
          <span slot="label"><i class="el-icon-edit"></i> 气郁质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions8" :key="item.id">
              <!--<p>{{item.question}}</p>-->
              <!--<el-radio-group v-model="isStart" v-show="item.isRadio==0" prop="question">
                <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.options" :key="value.id"></el-radio>
              </el-radio-group>-->
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div><!--{{questions}}-->
          </el-form>
        </el-tab-pane>
        <el-tab-pane >
          <span slot="label"><i class="el-icon-edit"></i> 特禀质</span>
          <el-form>
            <div class="questionDiv" v-for="(item) in questions9" :key="item.id">
              <!--<p>{{item.question}}</p>-->
              <!--<el-radio-group v-model="isStart" v-show="item.isRadio==0" prop="question">
                <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.options" :key="value.id"></el-radio>
              </el-radio-group>-->
              <el-form-item :label="item.question" prop="selectOption" v-show="item.isRadio==0">
                <el-radio-group v-model="item.answers">
                  <el-radio border v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-radio>
                </el-radio-group>
              </el-form-item>
              <el-form-item :label="item.question" prop="checkOptions" v-show="item.isRadio==1">
                <el-checkbox-group v-model="item.checkOptions">
                  <el-checkbox border  v-for="value in item.tAssessQuestionOptionList" :label="value.id" :value="value.id" :key="value.id">{{value.options}}</el-checkbox>
                </el-checkbox-group>
              </el-form-item>

            </div>
          </el-form>
        </el-tab-pane>
      </el-tabs>
      <div v-show="this.questions1 =='' ">
        <hr><br>
        暂无数据
      </div>
      <!--{{bodyModel}}-->
    </el-form>
    <span slot="footer" class="dialog-footer" v-show="dialogProps.action=='edit'||dialogProps.action=='add'">
      <el-button size="small" @click="handleDialogClose()">取 消</el-button>
      <el-button type="primary" size="small" @click="submitForm('bodyTypeForm')">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  import axios from 'axios'
  import { updateTBodyType,saveTBodyType, querySunQuestion, queryRainQuestion,
    queryQiQuestion, queryPingQuestion, queryTanQuestion, queryShiQuestion,
    queryXueQuestion, queryYuQuestion, queryTeQuestion,
    querySunQuestions, queryRainQuestions,
    queryQiQuestions, queryPingQuestions, queryTanQuestions, queryShiQuestions,
    queryXueQuestions, queryYuQuestions, queryTeQuestions } from '@/api/xy/body'
  import { queryIdCardByName } from '@/api/xy/assess'

  export default {
    name: 'body-edit',
    data() {
      return {
        loading: false,
        bodyModel: {},
        dialogProps: {
          visible:false,
          action: '',
          title: '',
          isAdd:null
        },
        formRules: {
        },
        memberId:0,
        questions1:[],
        questions2:[],
        questions3:[],
        questions4:[],
        questions5:[],
        questions6:[],
        questions7:[],
        questions8:[],
        questions9:[],
        questionTotal:[],
        memberList:[]
      }
    },
    methods: {
      selectIdCard(){
        this.$forceUpdate();
      },
      queryIdCard(){
          //alert(1);
            if(this.bodyModel.name=='undefined'||this.bodyModel.name==''){

            }else{
              queryIdCardByName(this.bodyModel.name).then((response)=>{

                this.memberList=response.data;

                this.bodyModel.idCard=this.memberList[0].idcard;

                //alert(this.memberList[0].idcard);
              });

            }

      },

      initAllQuestion(){
        this.questionTotal=[];
        //this.loading = true;
        //alert(this.memberId);
        querySunQuestions()
        .then(response => {
          this.questions1 = response.data;
          for(var i=0;i<this.questions1.length;i++){
            if(this.questions1[i].isRadio==1){
              this.$set(this.questions1[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions1[i],'answers', 0); //起作用
              this.$set(this.questions1[i],'selectOption',this.bodyModel.id); //起作用
            }
          }
          this.questionTotal.push(this.questions1);
        })
        .catch(error => {
          console.log(error)
          this.loading = false;
        })

        queryRainQuestions()
        .then(response => {
          this.questions2 = response.data;
          for(var i=0;i<this.questions2.length;i++){
            if(this.questions2[i].isRadio==1){
              this.$set(this.questions2[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions2[i],'answers', 0); //起作用
              this.$set(this.questions2[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions2);
        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryQiQuestions()
        .then(response => {
          this.questions3=response.data;
          for(var i=0;i<this.questions3.length;i++){
            if(this.questions3[i].isRadio==1){
              this.$set(this.questions3[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions3[i],'answers', Number.parseInt(this.questions3[i].answers)); //起作用
              this.$set(this.questions3[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions3);
        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryPingQuestions()
        .then(response => {
          this.questions4=response.data;
          for(var i=0;i<this.questions4.length;i++){
            //alert(this.questions4[i].isRadio);
            if(this.questions4[i].isRadio==0){
              //alert('msg');
              /*var array=[];
              array.push(this.questions4[i].answers);*/
              //alert(array);
              this.$set(this.questions4[i],'selectOption',this.bodyModel.id); //起作用

              this.$set(this.questions4[i],'answers', Number.parseInt(this.questions4[i].answers)); //起作用
            }
          }
          //alert(this.questions4[0].tAssessQuestionOptionList);
          this.questionTotal.push(this.questions4);

        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryTanQuestions()
        .then(response => {
          this.questions5=response.data;
          for(var i=0;i<this.questions5.length;i++){
            if(this.questions5[i].isRadio==1){
              this.$set(this.questions5[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions5[i],'selectOption',this.bodyModel.id); //起作用

              this.$set(this.questions5[i],'answers', Number.parseInt(this.questions5[i].answers)); //起作用
            }
          }
          this.questionTotal.push(this.questions5);
        })
        .catch(error => {
          console.log(error)
          this.loading = false;
        })

        queryShiQuestions()
        .then(response => {
          this.questions6=response.data;
          for(var i=0;i<this.questions6.length;i++){
            if(this.questions6[i].isRadio==1){
              this.$set(this.questions6[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions6[i],'answers', Number.parseInt(this.questions6[i].answers)); //起作用
              this.$set(this.questions6[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions6);

        })
        .catch(error =>{
          console.log(error);
          this.loading = false;
        })

        queryXueQuestions()
        .then(response => {
          this.questions7=response.data;
          for(var i=0;i<this.questions7.length;i++){
            if(this.questions7[i].isRadio==1){
              this.$set(this.questions7[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions7[i],'answers', Number.parseInt(this.questions7[i].answers)); //起作用
              this.$set(this.questions7[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions7);

        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryYuQuestions()
        .then( response => {
          this.questions8=response.data;
          for(var i=0;i<this.questions8.length;i++){
            if(this.questions8[i].isRadio==1){
              this.$set(this.questions8[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions8[i],'answers', Number.parseInt(this.questions8[i].answers)); //起作用
              this.$set(this.questions8[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions8);

        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryTeQuestions()
        .then(response => {
          this.questions9=response.data;
          for(var i=0;i<this.questions9.length;i++){
            if(this.questions9[i].isRadio==1){
              this.$set(this.questions9[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions9[i],'answers', Number.parseInt(this.questions9[i].answers)); //起作用
              this.$set(this.questions9[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions9);

        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })
        //alert(this.questionTotal.length);
      },
      initQuestion(){
        this.questionTotal=[];
        //this.loading = true;
        //alert(this.memberId);
        querySunQuestion(this.memberId)
        .then(response => {
          this.questions1 = response.data;
          for(var i=0;i<this.questions1.length;i++){
            if(this.questions1[i].isRadio==1){
              this.$set(this.questions1[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions1[i],'answers', Number.parseInt(this.questions1[i].answers)); //起作用
              this.$set(this.questions1[i],'selectOption',this.bodyModel.id); //起作用
            }
          }
          this.questionTotal.push(this.questions1);
        })
        .catch(error => {
          console.log(error)
          this.loading = false;
        })

        queryRainQuestion(this.memberId)
        .then(response => {
          this.questions2 = response.data;
          for(var i=0;i<this.questions2.length;i++){
            if(this.questions2[i].isRadio==1){
              this.$set(this.questions2[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions2[i],'answers', Number.parseInt(this.questions2[i].answers)); //起作用
              this.$set(this.questions2[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions2);
        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryQiQuestion(this.memberId)
        .then(response => {
          this.questions3=response.data;
          for(var i=0;i<this.questions3.length;i++){
            if(this.questions3[i].isRadio==1){
              this.$set(this.questions3[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions3[i],'answers', Number.parseInt(this.questions3[i].answers)); //起作用
              this.$set(this.questions3[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions3);
        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryPingQuestion(this.memberId)
        .then(response => {
          this.questions4=response.data;
          for(var i=0;i<this.questions4.length;i++){
            //alert(this.questions4[i].isRadio);
            if(this.questions4[i].isRadio==0){
              //alert('msg');
              /*var array=[];
              array.push(this.questions4[i].answers);*/
              //alert(array);
              this.$set(this.questions4[i],'selectOption',this.bodyModel.id); //起作用

              this.$set(this.questions4[i],'answers', Number.parseInt(this.questions4[i].answers)); //起作用
            }
          }
          //alert(this.questions4[0].tAssessQuestionOptionList);
          this.questionTotal.push(this.questions4);

        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryTanQuestion(this.memberId)
        .then(response => {
          this.questions5=response.data;
          for(var i=0;i<this.questions5.length;i++){
            if(this.questions5[i].isRadio==1){
              this.$set(this.questions5[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions5[i],'selectOption',this.bodyModel.id); //起作用

              this.$set(this.questions5[i],'answers', Number.parseInt(this.questions5[i].answers)); //起作用
            }
          }
          this.questionTotal.push(this.questions5);
        })
        .catch(error => {
          console.log(error)
          this.loading = false;
        })

        queryShiQuestion(this.memberId)
        .then(response => {
          this.questions6=response.data;
          for(var i=0;i<this.questions6.length;i++){
            if(this.questions6[i].isRadio==1){
              this.$set(this.questions6[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions6[i],'answers', Number.parseInt(this.questions6[i].answers)); //起作用
              this.$set(this.questions6[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions6);

        })
        .catch(error =>{
          console.log(error);
          this.loading = false;
        })

        queryXueQuestion(this.memberId)
        .then(response => {
          this.questions7=response.data;
          for(var i=0;i<this.questions7.length;i++){
            if(this.questions7[i].isRadio==1){
              this.$set(this.questions7[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions7[i],'answers', Number.parseInt(this.questions7[i].answers)); //起作用
              this.$set(this.questions7[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions7);

        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryYuQuestion(this.memberId)
        .then( response => {
          this.questions8=response.data;
          for(var i=0;i<this.questions8.length;i++){
            if(this.questions8[i].isRadio==1){
              this.$set(this.questions8[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions8[i],'answers', Number.parseInt(this.questions8[i].answers)); //起作用
              this.$set(this.questions8[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions8);

        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })

        queryTeQuestion(this.memberId)
        .then(response => {
          this.questions9=response.data;
          for(var i=0;i<this.questions9.length;i++){
            if(this.questions9[i].isRadio==1){
              this.$set(this.questions9[i],'checkOptions', []); //起作用
            }else{
              this.$set(this.questions9[i],'answers', Number.parseInt(this.questions9[i].answers)); //起作用
              this.$set(this.questions9[i],'selectOption',this.bodyModel.id); //起作用

            }
          }
          this.questionTotal.push(this.questions9);

        })
        .catch(error => {
          console.log(error);
          this.loading = false;
        })
        //alert(this.questionTotal.length);
      },
     /* submitForm() {
        this.questionTotal[0].selectOption=this.bodyModel.id;
        alert(this.questionTotal[0].selectOption);
        axios.post("/tBodyType/updateTBodyType",this.questionTotal).then(()=>{
          this.$message({
            message: '修改成功！',
            type: 'success'
          });
        })
      },*/
      submitForm() {
        //this.questionTotal[0].selectOption=this.bodyModel.id;
//alert(this.dialogProps.action );
        //修改
        if(this.dialogProps.action =='edit'){
              this.loading = true
              updateTBodyType(this.bodyModel.id,this.questionTotal)
                .then(response => {
                  this.$message({
                    message: '修改成功！',
                    type: 'success'
                  })
                  this.loading = false
                  this.dialogProps.visible = false
                  this.$emit('save-finished')
                })
                .catch(error => {
                  alert(error);
                  this.outputError(error)
                })
        //添加
        }else if(this.dialogProps.action =='add'){
            this.loading = true
              saveTBodyType(this.bodyModel.idCard,this.questionTotal)
                .then(response => {
                  this.$message({
                    message: '添加成功！',
                    type: 'success'
                  })
                  this.loading = false
                  this.dialogProps.visible = false
                  this.$emit('save-finished')
                })
                .catch(error => {
                  //alert(error);
                  this.outputError(error)
                })
        }

      },
      doSaveRole() {
        this.loading = true
        saveTBodyType(this.bodyModel)
          .then(response => {
            this.loading = false
            this.dialogProps.visible = false
            //刷新
            this.$emit('save-finished')
          })
          .catch(error => {
            this.outputError(error)
          })
      },
      handleDialogClose() {
        this.dialogProps.visible = false;
      },
      handleDialogOpen() {
        this.$nextTick(() => {
          this.$refs['bodyTypeForm'].clearValidate()
          //this.$refs['code'].focus()
        })
      },
      outputError(error) {
        console.log(error.response ? error.response : error.message)
        this.loading = false
        this.$message({
          showClose: true,
          message: '出错了，请按F12查看浏览器日志。',
          type: 'error'
        })
      }
    },
    mounted: function() {

      this.$nextTick(() => {
        this.$on('openEditBodyDialog', function(body,memberId) {
          this.bodyModel = body
          this.memberId=memberId;
          //alert(memberId);

          this.dialogProps.action = 'edit'
          this.dialogProps.isAdd=false
          this.dialogProps.title = '修改体制测评结果'
          this.dialogProps.visible = true
          this.initQuestion();
          this.queryIdCard();
        })
        this.$on('openAddBodyDialog', function() {
          //Object.assign(this.$data)
          this.bodyModel={};

          /*for(var j=0;j<this.questionTotal.length;j++){
              var questions=this.questionTotal[j];
              //alert(this.questionTotal[j]);
              for(var i=0;i<questions.length;i++){
                  if(questions[i].isRadio==1){
                    this.$set(questions[i],'checkOptions', []); //起作用
                  }else{
                    this.$set(questions[i],'answers', questions[i].tAssessQuestionOptionList[0].id); //起作用
                  }
              }
          }*/
          this.dialogProps.action = 'add'
          this.dialogProps.isAdd=true
          this.dialogProps.title = '新增体制测评'
          this.dialogProps.visible = true
           this.initAllQuestion();

        })
        //查看
        this.$on("openReadBodyDialog",function (body,memberId) {
          this.memberId=memberId;
          this.bodyModel = body;
          this.dialogProps.action = 'read'
          this.dialogProps.isAdd=false
          this.dialogProps.title = '查看详情'
          this.dialogProps.visible = true

           this.initQuestion();
          this.queryIdCard();

        })
      })
    },
    created() {
    }
  }
</script>

